package com.ssy.lingxi.common.constant.contract;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;

/**
 * 寻源类型
 * @author 伍将
 * @date 2021/2/2
 * @version 2.0.0
 */
public enum ContractSourceTypeEnum {

    ALL(0, "所有类型"),
    PURCHASE_INQUIRY(1, "采购询价"),
    PURCHASE_INVITE_BID(2, "采购招标"),
    PURCHASE_VIA_PRICE(3, "采购竞价");

    private final Integer code;
    private final String name;

    ContractSourceTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return LanguageHolder.getName(this.getClass(), this.code);
    }

    public static String getNameByCode(Integer code) {
        return Arrays.stream(ContractSourceTypeEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(ALL).getName();
    }
}
